package com.blockmeta.bbs.businesslibrary.widget;

import android.content.Context;
import androidx.annotation.Nullable;
import android.util.AttributeSet;

import skin.support.widget.SkinCompatTextView;

/**
 * @author AirThor
 * @date 2018/6/21.
 * 宽度固定为屏幕宽度的0.35
 */

public class ConstantTextView extends SkinCompatTextView {
    private int mScreenWidth = getContext().getResources().getDisplayMetrics().widthPixels;

    public ConstantTextView(Context context) {
        super(context);
    }

    public ConstantTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public ConstantTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        setMeasuredDimension((int) (mScreenWidth*0.35),heightMeasureSpec);
    }
}
